package com.aipanda.entity;

import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;

/**
 * 订单退款类
 * @param sn				编号
 * @param type				支付类型
 * @param paymentMethod		支付方式
 * @param bank				退款银行
 * @param account			退款账号
 * @param amount			退款金额
 * @param payee				收款人
 * @param operator			操作员
 * @param memo				备注
 * @param order				订单[多对一关系]
 * @author wanyuxiang
 *
 */
@Entity
@Table(name = "aipanda_refunds")
public class Refunds extends BaseEntity {
	private static final long serialVersionUID = 354885216604823632L;
	private String sn;
	private Type type;
	private String paymentMethod;
	private String bank;
	private String account;
	private BigDecimal amount;
	private String payee;
	private String operator;
	private String memo;
	private Order order;

	/**
	 * @param online 在线支付
	 * @param offline 线下支付
	 * @param deposit 预存款支付
	 * @author wanyuxiang
	 *
	 */
	public enum Type {
		online, offline, deposit;
	}

	@Column(nullable = false, updatable = false, unique = true)
	public String getSn() {
		return this.sn;
	}

	public void setSn(String sn) {
		this.sn = sn;
	}

	@NotNull
	@Column(nullable = false, updatable = false)
	public Type getType() {
		return this.type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	@Column(name="payment_method",updatable = false)
	public String getPaymentMethod() {
		return this.paymentMethod;
	}

	public void setPaymentMethod(String paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	@Length(max = 255)
	@Column(updatable = false)
	public String getBank() {
		return this.bank;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	@Length(max = 255)
	@Column(updatable = false)
	public String getAccount() {
		return this.account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	@NotNull
	@Min(0L)
	@Digits(integer = 15, fraction = 6)
	@Column(nullable = false, updatable = false, precision = 21, scale = 6)
	public BigDecimal getAmount() {
		return this.amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	@Length(max = 255)
	@Column(updatable = false)
	public String getPayee() {
		return this.payee;
	}

	public void setPayee(String payee) {
		this.payee = payee;
	}

	@Column(nullable = false, updatable = false)
	public String getOperator() {
		return this.operator;
	}

	public void setOperator(String operator) {
		this.operator = operator;
	}

	@Length(max = 255)
	@Column(updatable = false)
	public String getMemo() {
		return this.memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@NotNull
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "orders", nullable = false, updatable = false)
	public Order getOrder() {
		return this.order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}
}
